{include file="header" title="$title" /}
    <div class="page-title i-card-main">
        <i class="iconfont icon-page"></i>
        <span>SUBMIT LIST</span>
    </div>
    <div class="i-card-main">
        <table class="table">
            <thead>
            <tr>
                <th>ID</th>
                <th>Title</th>
                <th>User</th>
                <th>Time</th>
                <th>Verify</th>
                <th>Value</th>
            </tr>
            </thead>
            <tbody></tbody>
        </table>
        <nav id="page" style="display: none;">
            <ul class="pagination justify-content-center">
            </ul>
        </nav>
    </div>
    {include file="footer" /}
</div>
<div class="modal fade" id="infoModal" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">详细信息</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" id="infoData"></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>
<script>
$(".loading").show();
$(".i-card-main").eq(1).hide();

$(document).ready(function(){
    $.get("/api/v1/getSubmitList?page=" + page,function(res){
        if(res.code !== 200) {
            layer.msg(res.data.msg);
            return;
        }
        const data = res.data.data;
        let html = "";
        for(let i = 0, len = data.length; i < len; i++){
            const {id, cid, uid, time, verify, value} = data[i];
            html += `<tr>
                        <th scope='row'>${id}</th>
                        <td>${cid}</td>
                        <td>${uid}</td>
                        <td>${timestampToTime(time)}</td>
                        <td><span class='badge badge-${verify ? 'success' : 'secondary'}'>${verify ? '正确' : '错误'}</span></td>
                        <td><span class='badge badge-info' value='${value}'>查看</span></td>
                    </tr>`;
        }
        pages(res)
        $("tbody").html(html);
        $(".loading").hide();
        $(".i-card-main").eq(1).show();
    });
});

$("tbody").on("click", "span.badge-info", function() {
    const id = $(this).parent().parent().children().eq(0).text();
    $.get("/api/v1/getSubmitList?page=" + page,function(res){
        if (res.code != 200) {
            layer.msg(res.data.msg);
            return;
        }
        const data = res.data.data;
        let html = "";
        for(let i = 0; i < data.length; i++){
            if(data[i].id == id){
                html += '<p>题目标题：'+ data[i].cid +'</p>';
                html += '<p>提交用户：'+ data[i].uid +'</p>';
                html += '<p>提交IP：'+ data[i].ip +'</p>';
                html += '<p>提交时间：'+ timestampToTime(data[i].time) +'</p>';
                html += '<p>提交内容：'+ data[i].value +'</p>';
                if(data[i].verify){
                    html += '<p>是否正确：<span class="badge badge-success">正确</span></p>';
                }else{
                    html += '<p>是否正确：<span class="badge badge-secondary">错误</span></p>';
                }
                $("#infoData").html(html);
            }
        }
    });
  $("#infoModal").modal("show");
});
</script>
 </body></html>